module.exports = function($scope, $modal, $state,  $resource, $stateParams, str2date, date2str, what){


	console.log('qunmeng');

	$scope.myKeyup = function() {
		console.log('aaaaaa');
	}


	

	$scope.searchform = {};
	/* 分页
     * ========================================= */
	$scope.maxSize = 5;            //最多显示多少个按钮
	$scope.bigCurrentPage = 1;      //当前页码
	$scope.itemsPerPage = 10;         //每页显示几条

	$scope.load = function () {

		var para = {
			'pageNo': $scope.bigCurrentPage,
			'pageSize': $scope.itemsPerPage,
		};

		//console.log($scope.searchform);

		para = angular.extend($scope.searchform, para);

		console.log(para);

		$resource('/api/as/wc/product/saleapplylist', {}, {}).save(para, function (res) {
			console.log(res);

			if (res.errcode !== 0) {
				alert(res.errmsg);
				return;
			}

			$scope.objs = res.data.results;
			$scope.bigTotalItems = res.data.totalRecord;

		});

	};
	$scope.load();


	$scope.up = function(obj){

		$resource('/api/as/wc/product/updateapplystate', {}, {}).save({
			'code' : obj.code, 'state' : '2'
		}, function (res) {
			console.log(res);

			if (res.errcode !== 0) {
				alert(res.errmsg);
				return;
			}

			alert('审核通过')
			$scope.load();
		});

	};



	$scope.down = function(obj){

		$resource('/api/as/wc/product/updateapplystate', {}, {}).save({
			'code' : obj.code, 'state' : '1'
		}, function (res) {
			console.log(res);

			if (res.errcode !== 0) {
				alert(res.errmsg);
				return;
			}

			alert('审核未通过')
			$scope.load();
		});
		
	};

};
